package com.woniu.humanresource.service.impl;

import com.woniu.humanresource.dao.CorporateBenefitsDao;
import com.woniu.humanresource.entity.CompensationScheme;
import com.woniu.humanresource.entity.CorporateBenefits;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.service.CorporateBenefitsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CorporateBenefitsServiceImpl implements CorporateBenefitsService {
    @Resource
    CorporateBenefitsDao corporateBenefitsDao;

    //添加
    @Override
    public void insertCorporateBenefits(CorporateBenefits corporateBenefits) {
        corporateBenefitsDao.insertCorporateBenefits(corporateBenefits);
    }

    //查询
    @Override
    public PageBean<CorporateBenefits> selectCorporateBenefits(CorporateBenefits corporateBenefitsc, int pageIndex, int pageSize) {
        //创建用于接收beanlist的对象
        List<CorporateBenefits> cblist = corporateBenefitsDao.selectCorporateBenefits(corporateBenefitsc, 1, 10);
        //封装pagebean并赋值
        PageBean<CorporateBenefits> pageBean=new PageBean<>();
        pageBean.setBeanList(cblist);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectCorporateBenefitsCount(corporateBenefitsc));
        return pageBean;
    }

    //删除
    @Override
    public void deleteCorporateBenefits(int id) {
        corporateBenefitsDao.deleteCorporateBenefits(9);
    }


    //条数
    @Override
    public int selectCorporateBenefitsCount(CorporateBenefits corporateBenefits) {
        int count = corporateBenefitsDao.selectCorporateBenefitsCount(corporateBenefits);
        return count;
    }

    //修改
    @Override
    public void updateCorporateBenefits(CorporateBenefits corporateBenefits) {
        corporateBenefitsDao.updateCorporateBenefits(corporateBenefits);
    }
}